<cfif IsUserInRole("Super User") or IsUserInRole("Regional Admin")>
	<cfinclude template="#request.pathToUI#/grids/orders.cfm" />
<cfelse>
	<div class="row">
		<div class="banner prepare-banner">
			<div class="banner-text">
				<span class="banner-header">Order Materials</span><br />
				<!--- <span class="banner-subheader">Last year 33,000 students attended Cash for College workshops</span> --->
			</div>
		</div>
	</div>
	<div class="row body-row">
		<div class="span3">
			<ul class="nav nav-tabs nav-stacked sidenav">
				<li><a href="#overview">Overview</a></li>
				<li><a href="#orders">Orders</a></li>
				<li><a href="#whats-next">What&rsquo;s Next</a></li>
			</ul>
		</div>
		<div class="span9 content">
			<section id="overview">
				<h3>Overview</h3>
				<h4>Materials Availability - IMPORTANT</h4>
				<ul>
					<li>Due to a major funding delay of the federal College Access Challenge Grant, Cash for College materials available for order and shipping are limited. Cash for College materials for the 2015 workshop season will include Cash for College posters, Cash for College folders, the new Fund Your Future Magazine, and volunteer t-shirts.</li>
					<li>Other materials such as Cash for College promotional flyers, Cal Grant, CA Dream Act and Middle Class Scholarship Flyers will be available for download in a black/white format for copying, or for printing at a local printer. Downloadable files are accessible when an order is placed.</li>
					<li><strong>For workshops scheduled within the first two weeks of January:</strong> The <strong><em>Fund Your Future Magazine</em></strong> will not be available for shipping until after the New Year. The <strong><em>Magazine</em></strong> will not be shipped for workshops scheduled within the first two weeks of January.  Please download the one-page program, bilingual flyers (Cal Grant, Middle Class Scholarship, CA Dream Act) available for coping or printing.</li>
				</ul>
				<h4>Place An Order</h4>
				<ul>
					<li>Please order for your workshop all at one time. If you forget an item, you can edit your order if it has not yet been approved. If it has already been approved and you need more quantities, 
					contact <a href="mailto:cashforcollege@csac.ca.gov">cashforcollege@csac.ca.gov</a>, or your regional lead office to assist you.</li>
					<li>You can place one order for all of your workshops, or order workshop by workshop with separate shipping locations.</li>
					<li>Please let us know when your organization or school shuts down for the holiday break and reopens. Use the Shipping Instructions to let us know.</li>
					<li>If you need more materials for your school, beyond what is needed for your workshop, then visit the Commission's Publications Order Page at <a href="http://www.publications.csac.ca.gov" target="_blank">www.publications.csac.ca.gov</a> to request additional Fund Your Future Magazines.</li>
				</ul>
				<h4>Order Confirmation &amp; Fulfillment</h4>
				<p>Due to the availability of workshop materials, we will begin expedited shipping materials for early January workshops the week of December 8. We will resume ground shipping the first</p>
				<p>You will receive two emails confirming your order</p>
				<ol>
					<li>After you have placed your order, and</li>
					<li>When it has shipped, including tracking information.</li>
				</ol>
				<h4>Track Delivery</h4>
				<p>Once your order has shipped, you will receive a FedEx tracking number so that you can track your shipment to delivery.</p>
			</section>
			<section id="workshops">
				<h3>Orders</h3>
				<cfscript>
					base = new assets.calgrants.com.Base();
					isOrderSeason = base.isOrderSeason();
					// order systems switched in 2014-2015
					orderType = IIf(request.currentProgramYear lt "2013-2014", DE("WMS"), DE("CSAC"));
					workshopIDs = "";
					orderedWorkshopIDs = "";
					unorderedWorkshopIDs = "";
					if (isOrderSeason) {
						workshopGateway = new assets.calgrants.com.gateway.WorkshopGateway();
						qWorkshops = workshopGateway.query(Organization_ID = request.authUser.organizationID, Program_Year = request.currentProgramYear);
						if (orderType eq "WMS") {
							orderGateway = new assets.calgrants.com.gateway.OrderGateway();
						} else {
							orderGateway = new assets.calgrants.com.gateway.CSACOrderGateway();
						}
						qOrders = orderGateway.query(Organization_ID = request.authUser.organizationID, Program_Year = request.currentProgramYear);
						workshopIDs = ValueList(qWorkshops.Workshop_ID);
						orderedWorkshopIDs = ValueList(qOrders.Workshop_IDs);
						for (i=1; i<=ListLen(workshopIDs); i++) {
							if (ListFind(orderedWorkshopIDs, ListGetAt(workshopIDs, i)) eq 0) {
								unorderedWorkshopIDs = ListAppend(unorderedWorkshopIDs, ListGetAt(workshopIDs, i));
							}
						}
					}
				</cfscript>
				<cfoutput>
					<form method="get">
						<div class="row-fluid">
							<div class="span12">
								<cfif request.authUser.organizationID eq 1237 or http_host eq "calgrants">
									<p><a href="?view=editCSACOrder&returnView=#view#&CSAC_Order_ID=0" class="btn btn-success">New Order</a></p>
								<cfelseif IsUserInRole("Site Contact") eq true>
									<p><a href="##" class="btn btn-success" onclick="alert('Site Contacts cannot place orders'); return false;">New Order</a></p>
								<cfelseif request.authUser.regionID eq 2>
									<p><a href="##" class="btn btn-success" onclick="alert('Region 2 orders are placed by the Capitol Regional Coordinator\, Sacramento Cal\-SOAP.\n\nIf you need additional materials for your school\, visit the CSAC ePubs site at www\.publications\.csac\.ca\.gov'); return false;">New Order</a></p>
								<cfelseif IsUserInRole("Organizer")>
									<cfif NOT isOrderSeason>
										<p><a href="##" class="btn btn-success" onclick="alert('The order system is closed until the next Cash for College workshop season.\n\nYou will be notified when the order system is available.'); return false;">New Order</a></p>
									<cfelse>
										<cfif ListLen(workshopIDs) eq 0>
											<p><a href="##" class="btn btn-success" onclick="alert('At least one workshop must be registered to place an order'); return false;">New Order</a></p>
										<cfelseif ListLen(unorderedWorkshopIDs) eq 0>
											<p><a href="##" class="btn btn-success" onclick="alert('There are no registered workshops that do not already have an order.\n\nIf you need additional materials for your school\, visit the CSAC ePubs site at www\.publications\.csac\.ca\.gov'); return false;">New Order</a></p>
										<cfelse>
											<!--- <p>The order system is momentarily unavailable.</p> --->
											<p><a href="?view=editCSACOrder&returnView=#view#&CSAC_Order_ID=0" class="btn btn-success">New Order</a></p>
										</cfif>
									</cfif>
								</cfif>
							</div>
						</div>
					</form>
				</cfoutput>
				<cfif isOrderSeason eq false>
					<cfoutput>
					<div class="alert alert-info notFound">We are not accepting orders for the #selectedProgramYear# program season</div>
					</cfoutput>
				<cfelseif qOrders.RecordCount gt 0>
					<table id="ordersTable" class="table table-hover table-bordered">
						<thead>
							<tr>
								<th>Order Date</th>
								<th>Recipient</th>
								<th>Ordered By</th>
								<th>Status</th>
								<th class="action"></th>
							</tr>
						</thead>
						<tbody>
							<cfoutput query="qOrders">
								<cfif orderType eq "WMS">
									<tr>
										<td>#DateFormat(Date_Created, "m/d/yyyy")#</td>
										<td>#Shipping_Organization#</td>
										<td>#Ordered_By_Full_Name#</td>
										<td>
											<cfif IsDate(Fulfillment_Date)>
												Shipped
											<cfelseif Approved eq 1>
												Approved
											<cfelse>
												Pending approval
											</cfif>
										</td>
										<td>
											<a href="?view=order&returnView=#view#&Order_ID=#Order_ID#" class="btn btn-success btn-block">View</a>
										</td>
									</tr>
								<cfelseif orderType eq "CSAC">
									<tr>
										<td>#DateFormat(Order_Date, "m/d/yyyy")#</td>
										<td>
											<cfif Institution_Type eq "College University">
												#College_University_Institution#
											<cfelseif Institution_Type eq "High School">
												#High_School_High_School#
											<cfelse>
												#Institution#
											</cfif>
										</td>
										<td>#Ordered_By_First_Name# #Ordered_By_Last_Name#</td>
										<td>#Status#</td>
										<td>
											<cfif IsUserInRole("Site Contact") OR NOT isOrderSeason OR Status neq "New">
												<a href="?view=csacOrder&returnView=#view#&CSAC_Order_ID=#CSAC_Order_ID#" class="btn btn-success btn-block">View</a>
											<cfelse>
												<a href="?view=editCSACOrder&returnView=#view#&CSAC_Order_ID=#CSAC_Order_ID#" class="btn btn-success btn-block">Edit</a>
											</cfif>
										</td>
									</tr>
								</cfif>
							</cfoutput>
						</tbody>
					</table>
				<cfelse>
					<div class="alert alert-info notFound">No orders</div>
				</cfif> 
			</section>
			<section id="whats-next">
				<h3>What&rsquo;s Next</h3>
				<h4>Promote Workshops</h4>
				<p>You've got a great foundation in place for your workshop. Now it's time to put together a plan to get the word out about your event.</p>
				<p><a href="?view=promote" class="btn btn-success">Do It Now</a></p>
			</section>
		</div>
	</div>
</cfif>